package com.lovegu.io;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;

/**
 * @author 老顾
 * @title: User
 * @projectName java-restudy
 * @email: 1437594522@qq.com
 * @date 2022/9/24 16:36
 */
public class User {
    private String name;
    private int age;
    private int gander;
    public User(String name, int age, int gander) {
        this.name = name;
        this.age = age;
        this.gander = gander;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public int getGander() {
        return gander;
    }
    public void setGander(int gander) {
        this.gander = gander;
    }

    @Test
    public void testObjectOut() throws Exception{
        //怼了一个string
        InputStream is = new FileInputStream("E:\\test\\a\\user.txt");
        ObjectInputStream oi  = new ObjectInputStream(is);
        User user = (User)(oi.readObject());
        System.out.println(user.getName());
        is.close();
        oi.close();
    }
}
